<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<!DOCTYPE HTML>
<html>
	<head>
		<%@ include file="/WEB-INF/jsp/inc/taglibs.jsp"%>
		<%@ include file="/WEB-INF/jsp/inc/meta.jsp"%>
		<script type="text/javascript"
			src="${approot}/resource/jquery/validate/jquery.validate.js"></script>
		<link href="${approot}/resource/jquery/validate/jquery.validate.css"
			rel="stylesheet" type="text/css" />
		<link href="${approot}/resource/jquery/validate/style.css"
			rel="stylesheet" type="text/css" />
		<script type="text/javascript">
            /* <![CDATA[ */
            jQuery(function(){
            	
               
                jQuery('#excerpt').validated(function(){
					alert("通过验证");
					do_pay_money();
				});
            });
            /* ]]> */
        </script>

		<script type="text/javascript">
        function do_pay_money()
        {   
            var str=$('#excerpt').serializeObject();
            var jsons = $.toJSON(str);
            
            pay_money(jsons);
        }


        function pay_money(jsons){
        	var str;
        	var payWise;
            if(document.getElementById('payWise_1').checked == true){
            	str = '您确认以【现金缴费】的方式处理本次操作吗?';
            	payWise = 0;
            }else if(document.getElementById('payWise_2').checked == true){
            	str = '您确认以【气票缴费】的方式处理本次操作吗?';
            	payWise = 1;
            }else if(document.getElementById('payWise_3').checked == true){
            	str = '您确认以【卡扣费】的方式处理本次操作吗?';
            	payWise = 2;
            	if(document.getElementById('card_number').value==''){
            		alert('您选择了【卡扣费】方式缴费，卡号不能为空');
            		return false;
            	}
            	if(document.getElementById('residual_money').value < document.getElementById('gas_money').value){
            		alert('您当前账户余额不足，请充值。');
            		return false;
            	}
            }else{
            	alert('系统异常');
            	return false;
            }
            var excerptId = document.getElementById('excerpt_id').value;
            var cardId = document.getElementById('card_id').value;
            var cardNumber = document.getElementById('card_number').value;
        	if(confirm(str)){
        		$.ajax({
		 		   	url:'${approot}/admin/excerpt/pay_money/'+excerptId+'/'+cardId+'/'+cardNumber+'/'+payWise,
		 		   	dataType: 'json',
		 		   	contentType: 'application/json',
		 			data:null,
		 			type:'post',
		 			beforeSend:function(){
		 			  // $('#main').disabled='true';
		 			},
		 			error:function(request){
		 				alert(S);
		 			},
		 			success:function(data){
		 			   if(data.msg=="error")
		 			   {
		 	 			   alert('缴费失败');
		 			   }
		 			   if(data.msg=="succ")
		 			   {
		 				  alert('缴费成功');
		 				  window.location.reload();
		 			   }
		 			}
		 		   });
        	}
 	    
 	}
 	
 	function show_card_number(number){
 		$.ajax( {
			url : '${approot}/admin/excerpt/get_card_list/' + number,
			dataType : 'json',
			contentType : 'application/json',
			data : null,//$.toJSON({'id':id}),
			type : 'post',
			beforeSend : function() {
				// $('#main').disabled='true';
			},
			error : function(request) {
				//alert(S);
			},
			success : function(data) {
				if (data.msg == "error") {
					alert('系统异常，获取用户卡列表失败');
				}
				if (data.msg == "succ") {
				}
				var popUp = document.getElementById("popupcontent");
				popUp.style.left = "100px";
				popUp.style.width = 600 + "px";
				popUp.innerHTML = data.sb.toString();
				popUp.style.visibility = "visible";
				document.getElementById('show_card_list').style.display = 'block';

		}
		});
 	}
 	
 	function hidePopup(){
		var popUp = document.getElementById("popupcontent");
		popUp.style.visibility = "hidden";
		popUp.innerHTML = "";
	}
	
	function hidePopupOther(){
		document.getElementById('card_id').value = '';
 		document.getElementById('card_number').value = '';
 		document.getElementById('residual_money').value = '';
 		document.getElementById('show_card_list').style.display = 'none';
 		
		var popUp = document.getElementById("popupcontent");
		popUp.style.visibility = "hidden";
		popUp.innerHTML = "";
	}
	
	function set_card_number(cardId,cardNumber,residualMoney){
		document.getElementById('card_id').value = cardId;
		document.getElementById('card_number').value = cardNumber;
		document.getElementById('residual_money').value = residualMoney;
	}
        </script>

	</head>
	<body style="background: #E8F5FE; padding: 15px 18px;" class="scroll_r">
		<div id="right_w">
			<p>
				当前位置：额外费用管理 >> 开关气
			</p>
		</div>

		<form method="post" name="unlockForm" action="${approot}/admin/cost/unlock_mod/${modType}" id="excerpt">
			<table border="0" cellpadding="0" cellspacing="1" width="92%"
				align="center" class="tab_l">
				<tr>
					<td>
						<b>请按要求填写：</b>
					</td>
					<td align="right">
						带<span style="color: #ff0000;">*</span>为必填
					</td>
				</tr>
			</table>
			<table border="0" cellpadding="0" cellspacing="1" width="92%"
				align="center" id="add_tab">
				<tr>
					<th width="20%">
						客户编号：
					</th>
					<td width="30%">
						<input id="customCode" name="customCode" value="${unlock.customCode}"/>
						<span style="color: #ff0000; margin: 0;">*</span>
						<input type="hidden" name="id" value="${unlock.id}">
					</td>

					<th width="20%">
						客户姓名：
					</th>
					<td width="30%">
						<input id="customName" name="customName" value="${unlock.customName}"/>
						<span style="color: #ff0000; margin: 0;">*</span>
					</td>
				</tr>
				<tr>
					<th width="20%">
						地址：
					</th>
					<td colspan="3">
						<input id="address" name="address" value="${unlock.address}"/>
						<span style="color: #ff0000; margin: 0;">*</span>
					</td>
				</tr>
				<tr>
					<th width="20%">
						联系电话：
					</th>
					<td width="30%">
						<input id="tel" name="tel" value="${unlock.tel}"/>
						<span style="color: #ff0000; margin: 0;">*</span>
					</td>

					<th width="20%">
						金额：
					</th>
					<td width="30%">
						<input id="price" name="price" value="${unlock.price}"/>
						<span style="color: #ff0000; margin: 0;">*</span>
					</td>
				</tr>
				
				<tr>
					<th width="20%">
						处理人：
					</th>
					<td width="30%">
						<input id="unlocker" name="unlocker" value="${unlock.unlocker}"/>
						<span style="color: #ff0000; margin: 0;">*</span>
					</td>

					<th width="20%">
						处理日期：
					</th>
					<td width="30%">
						<input id="unlockDate" name="unlockDate" value="${unlock.unlockDate}" class="Wdate" onFocus="WdatePicker({startDate:'%y-%M-01 00:00:00',dateFmt:'yyyy-MM-dd',alwaysUseStartDate:true})"/>
						<span style="color: #ff0000; margin: 0;">*</span>
					</td>
				</tr>
				<tr>
					<th width="20%">
						备注：
					</th>
					<td colspan="3">
						<input id="remark" name="remark" value="${unlock.remark}"/>
						<span style="color: #ff0000; margin: 0;">*</span>
					</td>
				</tr>
			</table>
			<p id="tab_but">
				<input type="button" value="确 定" onclick="document.unlockForm.submit();">
			</p>
		</form>
	</body>
</html>
